package com.cbg.config;

import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger设置
 *
 * @author wangjuzheng
 * @date 2019-08-14
 **/
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class EsSearchManageSwagger2Config {


    @Bean
    public Docket searchDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false)
                .groupName("全景通查")
                .apiInfo(apiInfo())
                .select()
                .apis(Predicates.or(RequestHandlerSelectors.basePackage("com.cbg.es.controller"),
                        RequestHandlerSelectors.basePackage("com.cbg.archives.controller"),
                        RequestHandlerSelectors.basePackage("com.cbg.label.controller")))
                .paths(PathSelectors.any())
                .build();
    }


    private ApiInfo apiInfo() {

        return new ApiInfoBuilder()
                .title("门户系统API开发文档")
                .description("本文档由数驭未来制作完成,保密性高，请勿泄露，否则后果自负")
                .version("1.0")
                .build();
    }
}
